<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>缴费记录</title>
	<link rel="stylesheet" type="text/css" href="../common/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../common/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../common/demo.css">
	<script type="text/javascript" src="../common/jquery.min.js"></script>
	<script type="text/javascript" src="../common/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../common/common.js"></script>
	<script type="text/javascript" src="../common/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>

<table id="dg" title="缴费记录" style="width: 99%;height:630px"
	   data-options="rownumbers:true,
						singleSelect:true,
						autoRowHeight:true,
						pagination:true,
						pageSize:20,
						url:'/manage/cost/list',
						method:'get',
						toolbar:'#tb'">
	<thead>
	<tr>
		<th data-options="field:'id',width:100,hidden:'true'">id</th>
		<th data-options="field:'chargeType',width:100">缴费类型</th>
		<th data-options="field:'money',width:100">缴费金额</th>
		<th data-options="field:'floorId',width:100">楼号</th>
		<th data-options="field:'unitId',width:100">单元号</th>
		<th data-options="field:'roomId',width:100">房间号</th>
		<th data-options="field:'createTime',width:190,align:'center',
					formatter: function (createTime, row, index) {
			       var datetime = dateFormatter(createTime); <!--value就是数据库具体的值-->
			       return datetime;
			    }">缴费时间</th>
	</tr>
	</thead>
</table>
<div id="tb" style="padding:2px 5px;">
	楼号：<input id="floorId" style="width:110px">
	单元号：<input id="unitId" style="width:110px">
	房间号：<input id="roomId" style="width:110px">
	缴费类型:
	<select id="chargeType" class="easyui-combobox" panelHeight="auto" style="width:100px">
		<option value="">全部</option>
		<option value="物业费">物业费</option>
		<option value="水费">水费</option>
		<option value="电费">电费</option>
		<option value="车位管理费">车位管理费</option>
		<option value="宽带费">宽带费</option>
	</select>
	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="searchA()">Search</a>
	<a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="add()" style="float:right">添加</a>
</div>

<div id="addForm" class="easyui-window" title="添加缴费记录" data-options="iconCls:'icon-save'" style="width:500px;height:400px;padding:10px;">
	<div class="easyui-panel" title="" style="width:100%;max-width:400px;padding:30px 60px;">
		<form id="add" method="post">
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" id="addFloorId" style="width:100%" data-options="label:'楼号:',required:true">
			</div>
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" id="addUnitId" style="width:100%" data-options="label:'单元号:',required:true">
			</div>
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" id="addRoomId" style="width:100%" data-options="label:'房间号:',required:true">
			</div>
			<div style="margin-bottom:20px">
				<select id="addChargeType" class="easyui-combobox" panelHeight="auto" style="width:180px">
					<option value="物业费">物业费</option>
					<option value="水费">水费</option>
					<option value="电费">电费</option>
					<option value="车位管理费">车位管理费</option>
					<option value="宽带费">宽带费</option>
				</select>
			</div>
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" id="addMoney" style="width:100%" data-options="label:'缴费金额:',required:true">
			</div>
		</form>
		<div style="text-align:center;padding:5px 0">
			<a href="javascript:void(0)" class="easyui-linkbutton" onclick="addCost()" style="width:80px">Submit</a>
		</div>
	</div>
</div>
</body>
<script type="text/javascript">
	$(function(){
		searchA();
	})
	function searchA(){
		var floorId = $('#floorId').val();
		var unitId = $('#unitId').val();
		var roomId = $('#roomId').val();
		var chargeType = $('#chargeType').val();
		var data = {
				floorId:floorId,
				unitId:unitId,
				roomId:roomId,
				chargeType:chargeType
		};
		var pager = $('#dg').datagrid({
			queryParams: data,
			//双击事件
			onDblClickRow :function(rowIndex,rowData){
				}
		}).datagrid('getPager');	// get the pager of datagrid
		pager.pagination({
			buttons:[{
				iconCls:'icon-edit',
				handler:function(){
					getSelected();
				}
			}]
		});
		pager.pagination().find('a.l-btn').tooltip({
			content: function(){
				var cc = $(this).find('span.l-btn-icon').attr('class').split(' ');
				var icon = cc[1].split('-')[1];
				return icon + ' page';
			}
		});
		$('#approve').window('close');
		$('#addForm').window('close');
	}

	function add(){
		$('#addForm').window('open');
	}

	function addCost(){
		var floorId = $('#addFloorId').val();
		var unitId = $('#addUnitId').val();
		var roomId = $('#addRoomId').val();
		var chargeType = $('#addChargeType').val();
		var money = $('#addMoney').val();
		var data = {
				floorId:floorId,
				unitId:unitId,
				roomId:roomId,
				money:money,
				chargeType:chargeType
		};
		$('#add').form('submit', {
			url: "/manage/cost/add",
			queryParams: data,
			onSubmit: function(){

			},
			success: function(data){
				var data = eval('(' + data + ')');
				if(data.code==10000){
					$.messager.alert('成功',"提交成功");
					var pager = $('#dg').datagrid('reload');
				}else{
					$.messager.alert('失败',"添加失败，该账号已存在");
				}

			},
			error: function(){
				$.messager.alert('失败',"联系管理员");
			}
		});
		$('#addForm').form('clear');
		$('#addForm').window('close');
	}
	</script>
</html>